home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel PPC / lib_std / NEWcharacter_ref.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  1.3 KB  |  74 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class CHARACTER_REF
  5.  
  6. inherit
  7.    BASIC_REF
  8.       undefine is_equal 
  9.       end;
  10.    COMPARABLE 
  11.       redefine infix "<", compare, fill_tagged_out_memory
  12.       end;
  13.    
  14. creation make
  15.  
  16. feature 
  17.    
  18.    item: CHARACTER;
  19.  
  20.    make(value: CHARACTER) is
  21.       do
  22.      item := value;
  23.       end;
  24.     
  25. feature
  26.    
  27.    set_item(value: like item) is
  28.       do
  29.      item := value;
  30.       end;
  31.  
  32.    infix "<" (other: like Current): BOOLEAN is
  33.      -- Is Current less than `other'?
  34.       do
  35.      Result := item < other.item
  36.       end;
  37.  
  38.    compare (other: like Current) : INTEGER is
  39.      -- Compare Current with `other'.
  40.      -- '<' <==> Result < 0
  41.      -- '>' <==> Result > 0
  42.      -- Otherwise Result = 0
  43.       do
  44.      Result := code - other.code
  45.       end;
  46.  
  47.    code: INTEGER is
  48.      -- ASCII code of Current
  49.       do
  50.      Result := item.code
  51.       end;
  52.    
  53.    to_upper: like Current is
  54.      -- Conversion of Current to upper case
  55.       do
  56.      !!Result.make (item.to_upper)
  57.       end;
  58.  
  59.    to_lower: like Current is
  60.      -- Conversion of Current to lower case
  61.       do
  62.      !!Result.make (item.to_lower)
  63.       end;
  64.  
  65. feature -- Object Printing :
  66.  
  67.    fill_tagged_out_memory is
  68.       do
  69.      tagged_out_memory.append("item: "); 
  70.      item.fill_tagged_out_memory;
  71.       end;
  72.  
  73. end -- CHARACTER_REF
  74.